﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Fierce.Core.Aop;
using Fierce.Entity.Basic;
using Fierce.MvcExtend.Controllers;
using Fierce.Utility.Helper;
using Microsoft.AspNetCore.Mvc;

namespace Fierce.Mvc.Areas.Basic.Controllers
{
    [Area("Basic")]
    public class UserDepartmentPostController : WorkController
    {
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Page(string id, string userid)
        {
            BasicUserDepartmentPost model = new BasicUserDepartmentPost();

            if (string.IsNullOrEmpty(id))
            {
                model.UserID = userid;
            }
            else { model = ServiceFactory.BasicUserDepartmentPost.Get(id); }

            return View(model);
        }

        public string Grid(string userid)
        {
            return JsonHelper.Serialize(ServiceFactory.BasicUserDepartmentPost.GetByUserID(userid));
        }

        public string Save(BasicUserDepartmentPost entity)
        {
            return ServiceFactory.BasicUserDepartmentPost.Save(entity).Serialize();
        }

        public string Remove(string id)
        {
            return ServiceFactory.BasicUserDepartmentPost.Delete(id).Serialize();
        }
    }
}